<?php
/**
 *============================================================================
 * Cornice PHP Framework & Website Builder
 * Freeware (f) 2011 by Inforo Software & Computer
 *============================================================================
 */
 
/**
 * Base controller class for layout,page,block
 * @author Nicola Dinh
 * @version 2011.04.2220
 */
class controller {

  /*
   * All properties
   */
  public $class_path = null;
  public $css_path = null;
  public $js_path = null;
  public $php_path = null;
  public $model = null;
  public $accessible = true;

  /**
   * Default instance level constructor
   */
  public function __construct() {
    //
  }
  
  /**
   * Render HTML of layout (including blocks & page inside)
   */
  public function render_html() {
    if (!file_exists($this->css_path)) {
      response::error("'".$this->css_path."' not found");
      exit;
    }
    if (!file_exists($this->js_path)) {
      response::error("'".$this->js_path."' not found");
      exit;
    }
    if (!file_exists($this->php_path)) {
      response::error("'".$this->php_path."' not found");
      exit;
    }    
  
    //prepare
    if ($this->accessible) {
      $this->prepare();
      echo "\r\n";
    }
  
    //render css
    if ($this->accessible) {
      echo "<style>\r\n";
      require_once($this->css_path);
      echo "</style>\r\n";
    }

    //render html
    if ($this->accessible) {
      require_once($this->php_path);
    }
    
    //render js
    if ($this->accessible) {
      echo "<script>\r\n";
      require_once($this->js_path);
      echo "</script>\r\n";
      $this->finish();
    }    
  }//render_html
}

//end of controller class
//============================================================================